package com.example.testingscaffolding.Read;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Service;

@Service
public class ReadConfig {
    @Autowired
    private Environment environment;

    public void print() {
        String name = environment.getProperty("app.name");

        if (environment.containsProperty("app.owner")) {
            System.out.println("app.owner是存在的");
        }
        Integer port = environment.getProperty("app.port", Integer.class, 9000);
        String str = String.format("读取的key,name=%s,port=%d", name, port);
        System.out.println("str="+str);

    }
}
